/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package br.com.pedidos.servidor.mb;

import br.com.pedidos.servidor.dao.AvaliacaoDAO;
import br.com.pedidos.servidor.entity.Avaliacao;
import java.io.Serializable;
import javax.faces.application.FacesMessage;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;
import javax.faces.context.FacesContext;

/**
 *
 * @author Weslley
 */
@ManagedBean
@RequestScoped
public class AvaliacaoMB implements Serializable {

    private static final long serialVersionUID = 1L;
    
    private Avaliacao avaliacao;
    
    public AvaliacaoMB() {
        avaliacao = new Avaliacao();
    }
    
    public void registraAvaliacao() {
        AvaliacaoDAO dao = new AvaliacaoDAO();
        dao.startOperation();
        dao.save(avaliacao);
        dao.stopOperation(true);
        
        FacesContext.getCurrentInstance().addMessage(null, new FacesMessage("Obrigado por compartilhar sua opinião conosco!", null));
    }

    // GETTERS AND SETTERS
    public Avaliacao getAvaliacao() {
        return avaliacao;
    }

    public void setAvaliacao(Avaliacao avaliacao) {
        this.avaliacao = avaliacao;
    }
}
